class Solution:
    def lemonadeChange(self, bills: List[int]) -> bool:
        dic = {5:0, 10:0, 20:0}
        for bill in bills:
            dic[bill] += 1
            if bill > 5:
                rest = bill - 5
                for i in [10, 5]:
                    cnt = min(dic[i], rest//i)
                    rest -= i*cnt
                    dic[i] -= cnt                  
                if rest: return False
        return True